package com.qs.education.bean.dao;

import java.util.List;

public interface IBaseDao<T> {
	/**
	 * Insert an entity to database
	 * @param obj The entity object
	 * @return True if save successfully, otherwise false.
	 */
	public boolean save(T obj);
	
	/**
	 * Update entity object to database
	 * @param obj The entity object
	 * @return True if update successfully, otherwise false.
	 */
	public boolean update(T obj) ;
	/**
	 * merge entity object to database
	 * @param obj The entity object
	 * @return True if update successfully, otherwise false.
	 */
	public  boolean merge(T obj);
	
	/**
	 * Get entity object by id
	 * @param clazz The class type of entity
	 * @param id The object id
	 * @return The entity object
	 */
	public T get(Class<T> clazz, Object id) ;

	
	/**
	 * 
	 * @author Arwen Liu
	 * @date 2018-10-26
	 * @param clazz the class type of entity
	 * @return the list of entity
	 */
	public List<T> getAll(Class<T> clazz);
	/**
	 * Delete entity object from database
	 * @param obj The entity object that will be deleted
	 * @return True if delete successfully, otherwise false.
	 */
	public boolean delete(T obj) ;

	/**
	 * Delete the list of entity objects
	 * @param entities
	 * @return True if delete successfully, otherwise false.
	 */
	public boolean batchDelete(List<T> entities);
	/**
	 * Delete entity object by id
	 * @param id The object id
	 * @param clazz The entity class
	 * @return True if delete successfully, otherwise false.
	 */
	public boolean delete(Object id, Class<T> clazz) ;
	
	/**
	 * Insert a list of object to database
	 * @param entityName
	 * @param list
	 */
	public void batchInsert(List<T> list) ;
}
